<?php
	//-------------------- SESSAGES ERROR ------------------
	if(count($this->messageError)>0){
		foreach ($this->messageError AS $key => $val){
			echo '<div class="listError" id="'.$key.'" rel="' . $val . '"></div>';
		}
	}
?>
<div class="module_user">
	<?php echo $this->render( $this->arrParam['controller'] . '/toolbar/left.php');?>
	<div class="center_user">
		<div class="block_thongTinTaiKhoan">
			<form name="appForm" method="post" action="" enctype="multipart/form-data">
				<div class="block_title">
					<?php echo $this->Title;?>
				</div>
				<div class="block_content">
					<?php
					$user_name = $this->Item['user_name'] . $this->formHidden('id',$this->Item['id']) . $this->formHidden('user_name',$this->Item['user_name']);
					$password = '<a href="'.$this->baseUrl('default/user/password').'">Đổi mật khẩu</a>';
					
					$member_hoten = $this->formText('member_hoten',$this->Item['member_hoten'],array('class'=>'txtmedium')) . '<div class="view_error" id="view_member_hoten"></div>';
					$slbNgaySinh = array('00' => 'Ngày','01' => '01','02' => '02','03' => '03','04' => '04','05' => '05','06' => '06','07' => '07','08' => '08','09' => '09');
					for($i = 10; $i<=31; $i++){
						$slbNgaySinh[$i] = $i;
					}
					
					$ngaythangnam = explode('/', $this->Item['member_ngaysinh']);
					$ngaysinh = $ngaythangnam[0];
					if(!empty($this->Item['ngaysinh'])){
						$ngaysinh = $this->Item['ngaysinh'];
					}
					$selectNgaySinh = $this->formSelect('ngaysinh',$ngaysinh,array(),$slbNgaySinh);
					$slbThangSinh = array('00' => 'Tháng','01' => '01','02' => '02','03' => '03','04' => '04','05' => '05','06' => '06','07' => '07','08' => '08','09' => '09','10' => '10','11' => '11','12' => '12');
					$thangsinh = $ngaythangnam[1];
					if(!empty($this->Item['thangsinh'])){
						$thangsinh = $this->Item['thangsinh'];
					}
					$selectThangSinh = $this->formSelect('thangsinh',$thangsinh,array(),$slbThangSinh);
					$slbNamSinh = array('00' => 'Năm');
					for($i = @date('Y') - 15; $i>=@date('Y') - 80; $i--){
						$slbNamSinh[$i] = $i;
					}
					$namsinh = $ngaythangnam[2];
					if(!empty($this->Item['namsinh'])){
						$namsinh = $this->Item['namsinh'];
					}
					$selectNamSinh = $this->formSelect('namsinh',$namsinh,array(),$slbNamSinh);
					$member_ngaysinh = $selectNgaySinh . ' ' . $selectThangSinh . ' ' . $selectNamSinh . '<div class="view_error" id="view_member_ngaysinh"></div>';
					$option_gioitinh = array('Nam' => 'Nam','Nữ' => 'Nữ');
					$gioitinh = 'Nam';
					if(!empty($this->Item['member_gioitinh'])){
						$gioitinh = $this->Item['member_gioitinh'];
					}
					$member_gioitinh 	= $this->formRadio('member_gioitinh',$gioitinh,null,$option_gioitinh, ' ');
					$member_yahoo 	= $this->formText('member_yahoo',$this->Item['member_yahoo'],array('class'=>'txtmedium'));
					$member_skype 	= $this->formText('member_skype',$this->Item['member_skype'],array('class'=>'txtmedium'));
			
					$current_user_avatar= $this->formHidden('current_user_avatar',$this->Item['member_avatar']);
					$user_avatar		= $this->formFile ('user_avatar', array ('style' => 'width:250px;')) . $current_user_avatar . '<div class="view_error" id="view_user_avatar"></div>';
					$member_avatar		= $this->imgUrl . '/user/user-img.jpg';
					if($this->Item['member_avatar'] != ''){
						$member_avatar		= FILE_URL . '/users/img450x450/' . $this->Item['member_avatar'];
					}
					
					$member_diachi = $this->formText('member_diachi',$this->Item['member_diachi'],array('class'=>'txtlong')) . '<div class="view_error" id="view_member_diachi"></div>';
					$slbCity = $this->city;
					$member_tinh = $this->formSelect('member_tinh',$this->Item['member_tinh'],array(),$slbCity) . '<div class="view_error" id="view_member_tinh"></div>';
					$member_dienthoai = $this->formText('member_dienthoai',$this->Item['member_dienthoai'],array('class'=>'txtmedium')) . '<div class="view_error" id="view_member_dienthoai"></div>';
					$member_email = $this->formText('member_email',$this->Item['member_email'],array('class'=>'txtmedium')) . '<div class="view_error" id="view_member_email"></div>';
					
					?>
					<div class="note">
						<p class="">Vui lòng điền đầy đủ thông tin</p>
						<p>Những mục có dấu <span class="star">*</span> là bắt buộc phải nhập </p>
					</div>
					<div class="item">
						<div class="item_title">Thông tin đăng nhập</div>
						<div class="item_content">
							<table style="width: 100%">
								<tr>
									<td style="width: 150px;" class="label"><b>Email Đăng nhập (<span class="star">*</span>)</b></td>
									<td><?php echo $user_name;?></td>
								</tr>
								<tr>
									<td class="label"><b>Mật khẩu (<span class="star">*</span>)</b></td>
									<td><?php echo $password;?></td>
								</tr>
							</table>
						</div>
					</div>
					
					<div class="item">
						<div class="item_title">Thông tin cá nhân</div>
						<div class="item_content">
							<table style="width: 100%">
								<tr>
									<td class="tbUser-row" width="140" valign="top" style="padding-top:8px">
										<img width="130" class="userImg" alt="avatar" src="<?php echo $member_avatar;?>">
									</td>
									<td valign="top" style="padding: 0 0 0 10px !important;">
										<table style="width: 100%">
											<tr>
												<td style="width: 150px;" class="label"><b>Họ và tên (<span class="star">*</span>)</b></td>
												<td><?php echo $member_hoten;?></td>
											</tr>
											<tr>
												<td class="label"><b>Ngày sinh (<span class="star">*</span>)</b></td>
												<td><?php echo $member_ngaysinh;?></td>
											</tr>
											<tr>
												<td class="label"><b>Giới tính (<span class="star">*</span>)</b></td>
												<td><?php echo $member_gioitinh;?></td>
											</tr>
											<tr>
												<td class="label"><b>Yahoo</b></td>
												<td><?php echo $member_yahoo;?></td>
											</tr>
											<tr>
												<td class="label"><b>Skype</b></td>
												<td><?php echo $member_skype;?></td>
											</tr>
											<tr>
												<td class="label"><b>Ảnh đại diện</b></td>
												<td><?php echo $user_avatar;?></td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</div>
					</div>
					
					<div class="item">
						<div class="item_title">Thông tin liên hệ</div>
						<div class="item_content">
							<table style="width: 100%">
								<tr>
									<td style="width: 150px;" class="label"><b>Địa chỉ</b></td>
									<td><?php echo $member_diachi;?></td>
								</tr>
								<tr>
									<td class="label"><b>Tính/Thành phố</b></td>
									<td><?php echo $member_tinh;?></td>
								</tr>
								<tr>
									<td class="label"><b>Số điện thoại</b></td>
									<td><?php echo $member_dienthoai;?></td>
								</tr>
								<tr>
									<td class="label"><b>Email</b></td>
									<td><?php echo $member_email;?></td>
								</tr>
							</table>
						</div>
					</div>
					
					<div class="block_botton">
						<?php echo $this->formSubmit('btn_submit','Lưu',array('class'=>'user_button goc5'));?>
						<?php echo $this->formButton('btn_reset','Làm lại',array('class'=>'user_button goc5 mrl10', 'onclick' => "window.location.href = '".$this->baseUrl('default/user/edit')."'"));?>
						<?php echo $this->formButton('btn_cancel','Đóng',array('class'=>'user_button goc5 mrl10', 'onclick' => "window.location.href = '".$this->baseUrl('default/user/index')."'"));?>
					</div>
					<div class="clr"></div>
				</div>
			</form>
			<script type="text/javascript">
				$("div.listError").each(function (i) {
			        //alert($(this).attr('rel'));
			        $('#view_' + $(this).attr('id')).html($(this).attr('rel'));
			    });
			</script>
		</div>
	</div>
	<div class="clr"></div>
</div>